package com.space.myapollo;

import java.util.List;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.space.myapollo.dto.UserInfoDto;
import com.space.myapollo.mapper.UserMapper;
import com.space.myapollo.model.User;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.oas.annotations.EnableOpenApi;

@SpringBootApplication
@MapperScan("com.space.myapollo.mappers")
@RestController
@EnableOpenApi
//@EnableSwagger2
@Api(tags = "启动demo")
public class MyapolloApplication {

	public static void main(String[] args) {
		SpringApplication.run(MyapolloApplication.class, args);
		System.out.println("------start service----");
	}

	@Value("${spring.datasource.driver-class-name}")
	private String driverName;
	
	@Autowired
	UserMapper userMapper;
	
	@GetMapping("/hello")
	@ApiOperation("欢迎测试")
	public String hello(@RequestParam(value="name", defaultValue="world")String name) {
		List<User> users = userMapper.selectList(null);
		users.forEach(System.out::println);
		UserInfoDto user = userMapper.selectDemo(3);
		return String.format("Hello %s!(%s)(%d)(%s)", name, driverName, users.size(),user.getName());
	}
}
